﻿<!--
 Peter
 Created by: Peter Development Team
    http://peter.codeplex.com/
 
 GNU General Public License version 2 (GPLv2)
    http://peter.codeplex.com/license
 
 This code is provided on an AS IS basis, with no WARRANTIES,
  CONDITIONS or GUARANTEES of any kind.
-->
<UserControl x:Class="Peter.View.ViewTerminal"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:logic="clr-namespace:Peter.Logic" 
             xmlns:avalonedit="http://icsharpcode.net/sharpdevelop/avalonedit"
             xmlns:icons="clr-namespace:Peter.Common.Icons;assembly=Peter.Common"
             xmlns:controls="clr-namespace:Peter.Common.Controls;assembly=Peter.Common"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300"
             d:DataContext="{d:DesignInstance logic:ModelTerminal}">
   <Grid>
      <Grid.RowDefinitions>
         <RowDefinition Height="*" />
         <RowDefinition Height="Auto" />
      </Grid.RowDefinitions>

      <Grid.ColumnDefinitions>
         <ColumnDefinition Width="Auto" />
         <ColumnDefinition Width="*" />
      </Grid.ColumnDefinitions>
      
      <StackPanel Grid.Column="0"
                  Grid.Row="0"
                  Grid.RowSpan="2">
         <ToggleButton IsChecked="{Binding Path=ShowLineNumbers, ElementName=_TextEditor, Mode=TwoWay}"
                       ToolTip="Show/Hide Line Numbers">
            <icons:IconDisplay Icon="Numberlist" />
         </ToggleButton>
         <ToggleButton IsChecked="{Binding Path=WordWrap, ElementName=_TextEditor, Mode=TwoWay}"
                       ToolTip="Wrap Text">
            <icons:IconDisplay Icon="AlignLeft" />
         </ToggleButton>
         <Button Command="{Binding Path=ClearCommand}"
                 ToolTip="Erase Output">
            <icons:IconDisplay Icon="Eraser" />
         </Button>
      </StackPanel>

      <avalonedit:TextEditor x:Name="_TextEditor"
                             Focusable="True"
                             IsReadOnly="True"
                             Grid.Row="0"
                             Grid.Column="1"
                             ShowLineNumbers="True">
         <avalonedit:TextEditor.ContextMenu>
            <ContextMenu>
               <MenuItem Header="Copy"
                         Command="Copy">
                  <MenuItem.Icon>
                     <icons:IconDisplay Icon="Copy"
                                        Margin="2" />
                  </MenuItem.Icon>
               </MenuItem>
               <MenuItem Header="Select All"
                         Command="SelectAll">
                  <MenuItem.Icon>
                     <icons:IconDisplay Icon="SelectionRectangleSelection"
                                        Margin="2" />
                  </MenuItem.Icon>
               </MenuItem>

            </ContextMenu>
         </avalonedit:TextEditor.ContextMenu>
      </avalonedit:TextEditor>

      <StackPanel Grid.Row="1"
                  Grid.Column="1">
         <StackPanel Orientation="Horizontal"
                       Margin="0,3">
            <TextBlock Text="CWD:"
                       FontStyle="Italic"
                       Margin="0,0,4,0" />
            <TextBlock Text="{Binding Path=CommandPrompt.WorkingDirectory}"
                       FontWeight="Bold" />
         </StackPanel>
         <controls:ComboBoxEx IsEditable="True"
                              StaysOpenOnEdit="True"
                              x:Name="_CommandLine"
                              CaretPosition="{Binding Path=CaretPosition}"
                              PreviewKeyDown="ComboBoxPreviewKeyDown"
                              ItemsSource="{Binding Path=CommandHistory}"
                              Text="{Binding Path=CommandLine, UpdateSourceTrigger=PropertyChanged}" />
      </StackPanel>
   </Grid>
</UserControl>
